package com.navinfo.gateway.platform.util.lang;

import java.io.UnsupportedEncodingException;


/**
 * 字符串工具类
 *
 * @author zhengshibo
 * @date 2018-03-14
 */
public class StringUtils {

	/**
	 * byte数组转gbk格式字符串
	 *
	 * @param bytes byte数组
	 * @return gbk格式字符串
	 */
	public static String bytesToGbkString(byte[] bytes) {
		try {
			return new String(bytes, "gbk");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			return "";
		}
	}

	/**
	 * byte数组转	utf8格式字符串
	 *
	 * @param bytes byte数组
	 * @return utf8格式字符串
	 */
	public static String bytesToUtf8String(byte[] bytes) {
		try {
			return new String(bytes, "utf8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			return "";
		}
	}

}
